# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=8
inherit gnome2-utils desktop

DESCRIPTION="Call of Duty"
HOMEPAGE=""
SRC_URI="http://fpemud-distfiles.local/pub/${PN}.zip
         http://fpemud-distfiles.local/pub/CoD_1.5_Patch.exe"
LICENSE=""
SLOT="0"
KEYWORDS="-* amd64 x86"
IUSE=""
RESTRICT="mirror"

DEPEND="app-arch/unzip"
RDEPEND="virtual/wine[abi_x86_32]"

S="${WORKDIR}"

src_unpack() {
	return
}

src_prepare() {
	eapply_user

	# Prepare the wrapper script
	sed -e "s/^GAMEDIR=.*$/GAMEDIR=\/opt\/${PN}/g" \
	    -e "s/^DATADIR=.*$/DATADIR=~\/.cache\/${PN}/g" \
	    -e "s/^CFGDIR=.*$/CFGDIR=~\/.config\/${PN}/g" "${FILESDIR}/${PN}" > "${WORKDIR}/${PN}"
}

src_install() {
	mkdir -p "${D}/opt/${PN}/CallofDuty"
	unzip "${DISTDIR}/${PN}.zip" -d "${D}/opt/${PN}/CallofDuty"

	dobin "${PN}"

	local res
	for res in 16 32; do
		newicon -s ${res} "${FILESDIR}/${PN}_${res}x${res}x8.png" "${PN}.png"
	done

	domenu "${FILESDIR}/${PN}.desktop"
}

pkg_preinst() {
	gnome2_icon_savelist
}

pkg_postinst() {
	gnome2_icon_cache_update
}

pkg_postrm() {
	gnome2_icon_cache_update
}

pkg_extra_files() {
	echo "~/.cache/call-of-duty/***"
}
